﻿using System;

[assembly: CLSCompliant(true)]

namespace PlayerService
{
    using System;
    using System.Collections.Generic;
    using DataClasses;

    public class MyPlayerService : IMyPlayerService
    {
        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }

        public Playlist[] GetAllPlaylists()
        {
            var pl = Playlist.Get().ToArray();
            return pl;
        }

        public Song[] GetPlSongs(Guid playlistid)
        {
            return new Playlist().GetSongs(playlistid).ToArray();
        }

        public Song[] GetAllSongs()
        {
            return Song.Get().ToArray();
        }

        public void SaveSong(Song song)
        {
            song.Save();
        }

        public void SavePlaylist(Playlist playlist)
        {
            playlist.Save();
        }

        public void DeletePLSongsBy(Guid id, string nameid)
        {
            var toDelete = PlaylistSong.GetById(id, nameid);
            foreach (var playlistSong in toDelete)
            {
                playlistSong.Delete();
            }
        }

        public void DeleteSong(Song song)
        {
            song.Delete();
        }

        public void DeletePlaylist(Playlist playlist)
        {
            playlist.Delete();
        }
    }
}
